#ifndef SM2_UTILS_H
#define SM2_UTILS_H

#include <stdint.h>
#include <stddef.h>

// SM2密钥结构
typedef struct {
    uint8_t x[32];
    uint8_t y[32];
} SM2_PublicKey;

typedef struct {
    uint8_t d[32];
} SM2_PrivateKey;

typedef struct {
    SM2_PublicKey public_key;
    SM2_PrivateKey private_key;
} SM2_KeyPair;

// 生成SM2密钥对
int sm2_generate_keypair(SM2_KeyPair *keypair);

// 使用SM2公钥加密数据
int sm2_encrypt(const uint8_t *data, size_t data_len, 
                const SM2_PublicKey *pub_key, 
                uint8_t *encrypted_data, size_t *encrypted_len);

// 使用SM2私钥解密数据
int sm2_decrypt(const uint8_t *encrypted_data, size_t encrypted_len, 
                const SM2_PrivateKey *priv_key, 
                uint8_t *decrypted_data, size_t *decrypted_len);

#endif // SM2_UTILS_H